﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace utd_hrrs
{
    public partial class _Default : System.Web.UI.Page
    {
        SqlConnection conn;

        protected void Page_Load(object sender, EventArgs e)
        {
            conn = new SqlConnection("Data Source=rockstar.hopto.org,11433;Initial Catalog=UTD_HRRS;Persist Security Info=True;User ID=utd_hrrs;Password=bhowmik6360");
        }

        protected void LogIn_Click(object sender, EventArgs e)
        {
            conn.Open();
            SqlCommand command = new SqlCommand("SELECT st_flag, sp_flag from user_data where user_id = '" + username.Text + "' and password = '" + Password.Text + "'", conn);
            SqlDataReader dr = command.ExecuteReader();
            if (dr.HasRows)
            {
                Response.Cookies["username"].Value = username.Text;

                dr.Read();
                if (dr.GetBoolean(1))
                {
                    Response.Redirect("Supervisor.aspx");
                }
                else
                {
                    Response.Redirect("user02.aspx");
                }
            }
            else
            {
                invalidSelection.Visible = true;
            }
        }
    }
}
